﻿using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;

namespace Entity
{
    /// <summary>
    /// 机器绑定记录
    /// </summary>
    public class Mch_bind_record
    {
        public string Id { get; set; }
        /// <summary>
        /// 0IC 1IC2 3绑定生产单
        /// </summary>
        public bind_type_enum Type_id { get; set; }
        /// <summary>
        ///  机器ID
        /// </summary>
        public string mchid { get; set; }
        /// <summary>
        ///  机器SN
        /// </summary>
        public string sn { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTime addtime { get; set; }
        /// <summary>
        /// 柜体码
        /// </summary>
        public string box_code { get; set; }
        /// <summary>
        ///  生产单码
        /// </summary>
        public string work_order_id { get; set; }
        /// <summary>
        ///  绑定生产单码
        /// </summary>
        public string work_order_details_id { get; set; }
        public string uid { get; set; }
        public string u_name { get; set; }

 
    }

    public class Mch_bind_record_search: Mch_bind_record
    {
        public string type_str { get { return Type_id.ToString() + "绑定"; } }
    }


    
     

    public enum bind_type_enum
    {
        IC = 0,
        IC2 = 1,
        按键机 = 2,
        生产单 = 10
    }
    /// <summary>
    /// 附属柜数据
    /// </summary>
    public class Mch_subsidiary
    {

        public string Id { get; set; }
        public string mchid { get; set; }

        public int box_no { get; set; }

        public DateTime addtime { get; set; }

        /// <summary>
        /// 颜色
        /// </summary>
        public string color { get; set; }
        /// <summary>
        /// 制冷
        /// </summary>
        public bool can_cold { get; set; }
        /// <summary>
        /// 制热
        /// </summary>
        public bool can_hot { get; set; }
        /// <summary>
        /// 是否负离子
        /// </summary>
        public bool can_anion { get; set; }
        /// <summary>
        /// 是否具备现金功能
        /// </summary>
        public bool can_cash { get; set; }

        /// <summary>
        /// 机器类型
        /// </summary>
        public Mch_Type Mch_Type { get; set; }
        /// <summary>
        /// 机器类型
        /// </summary>
        public string mch_kid_type { get; set; }
        /// <summary>
        /// 机器类型id (选择时使用)
        /// </summary>
        public string mch_kid_type_id { get; set; }
        /// <summary>
        /// 货道模板id
        /// </summary>
        public string slot_template_id { get; set; }

        /// <summary>
        /// 显示在纸张上的生产单号
        /// </summary>
        public string print_work_No { get; set; }

        public string work_baseuserid { get; set; }

        public string baseuserid { get; set; }
        /// <summary>
        /// 所属生产单
        /// </summary>
        public string work_order_id { get; set; }
        /// <summary>
        /// 柜体码
        /// </summary>
        public string box_code { get; set; }
    }


    public class Mch : BaseEnity
    {

        //[Required]
        public string SN { get; set; }//SN
        //[Required]
        public string Name { get; set; }//名称
        public string Number { get; set; }//编号
        public string GroupId { get; set; }  //场地 
        public MchState State { get; set; }
        public bool IsOnLine { get; set; }  //是否在线  
        [NotMapped]
        public string StateName { get; set; }
        [NotMapped]
        public string GroupName { get; set; }  //场地 
        public string BaseUserId { get; set; }  //信号   
        public string Key { get; set; }  //信号 
        public string Remark { get; set; }  //备注   
        public bool Active { get; set; }  //是否激活   
        [Required]
        public string MchMode { get; set; }  //机器型号  
        public string Address { get; set; }  //详细地址
        public string Lng { get; set; }
        public string Lat { get; set; }

        public string PlaceId { get; set; }
        public decimal? BillChangefundAmount { get; set; }//纸币数
        public decimal? CoinChangefundAmount { get; set; }// 硬币数

        public bool IsAutoRefund { get; set; }//是否出货失败自动退款
        public string TmpStrategyId { get; set; }//温度策略ID
        public string TmpStrategyContent { get; set; }//温度策略内容
        public string LightStrategyId { get; set; }//灯光策略ID
        public string PriceStrategyId { get; set; }//价格策略ID

        public string AdId { get; set; }//广告策略ID

        public string channelId { get; set; }//安卓版本

        public string ConnUpdateOn { get; set; }//连接状态改变

        public string MchVesion { get; set; }//程序版本 

        public bool OrderFromClient { get; set; }//部分定值机客户端计算价格 
        /// <summary>
        /// 出厂日期
        /// </summary>
        public DateTime? OutTime { get; set; }
        /// <summary>
        /// 指定保修时间
        /// </summary>
        public int? AddMonth { get; set; }
        /// <summary>
        /// 保修日期
        /// </summary>
        public DateTime? GuaranteeTime { get; set; }
        /// <summary>
        /// 设备所属批次
        /// </summary>
        public string BatchID { get; set; }

        /// <summary>
        /// 当前真实的掉货检测值
        /// </summary>
        public bool TrueDropCheck { get; set; }
        /// <summary>
        /// 设置是否开启掉货检测
        /// </summary>
        public bool SetDropCheck { get; set; }
        /// <summary>
        /// 是否启用页面mqtt通讯
        /// </summary>
        public bool RunPageOnline { get; set; }

        public string ParentId { get; set; }

        public string mchmode_batchno { get; set; }
        public string province { get; set; }
        public string city { get; set; }

        public string district { get; set; }
        /// <summary>
        /// 当前亮度
        /// </summary>
        public decimal? brightness { get; set; }

        /// <summary>
        /// 当前广告ID
        /// </summary>
        public string now_ad_id { get; set; }
        /// <summary>
        ///  当年广告名称
        /// </summary>
        public string now_ad_name { get; set; }
        /// <summary>
        /// 广告类型
        /// </summary>
        public int ad_type { get; set; }
        /// <summary>
        ///  广告是否下发 成功
        /// </summary>
        public bool? ad_success { get; set; }

        public string Daemon_channelId { get; set; }//安卓版本

        public string Daemon_ConnUpdateOn { get; set; }//连接状态改变
        public bool Daemon_IsOnline { get; set; }
        /// <summary>
        /// 守护程序上次上级时间
        /// </summary>
        public DateTime? Daemon_lastupdate_time { get; set; }
        /// <summary>
        /// 守护程序上次升级成功时间
        /// </summary>
        public DateTime? Daemon_lastupdatesuccess_time { get; set; }
        /// <summary>
        /// 守护程序版本
        /// </summary> 
        public string Daemon_Version { get; set; }
        /// <summary>
        /// 守护程序版本备注
        /// </summary> 
        public string Daemon_updateRemark { get; set; }
        /// <summary>
        /// 守护程序包名
        /// </summary>
        public string Daemon_packageName { get; set; }
        /// <summary>
        /// 程序升级情况
        /// </summary>
        public updateState Daemon_updateState { get; set; } = updateState.升级成功;

        /// <summary>
        /// 当前使用版本
        /// </summary> 
        public string app_Version { get; set; }
        /// <summary>
        /// 程序升级情况
        /// </summary>
        public updateState app_updateState { get; set; } = updateState.升级成功;
        /// <summary>
        /// 程序升级备注
        /// </summary> 
        public string app_updateRemark { get; set; }
        /// <summary>
        /// 当前使用的包名
        /// </summary>  
        public string packageName { get; set; } = "unknow";
        /// <summary>
        /// App上次升级时间
        /// </summary>
        public DateTime? app_lastupdate_time { get; set; }
        /// <summary>
        /// APP上次升级成功时间
        /// </summary>
        public DateTime? app_lastupdatesuccess_time { get; set; }
        /// <summary>
        /// 项目ID 
        /// </summary>
        public string AppProject_Id { get; set; }

        /// <summary>
        /// 微信截图
        /// </summary>
        public string wxrecord_screenshot { get; set; }
        /// <summary>
        ///  理货后微信截图
        /// </summary>
        public string tallyafter_screenshot { get; set; }
        public string MchType { get; set; }
        /// <summary>
        /// 质保开始时间
        /// </summary>
        public DateTime? assurance_sdt { get; set; }

        public int IC2_max_lattices { get; set; }

        public string service_tel { get; set; }
        /// <summary>
        /// 生产所属人
        /// </summary>
        public string work_baseuserid { get; set; }

        public string work_order_id { get; set; }

        public DateTime? work_order_time { get; set; }
        /// <summary>
        /// 柜体码
        /// </summary>
        public string box_code { get; set; }
        /// <summary>
        /// 机器销售经理ID
        /// </summary>
        public string sale_uid { get; set; }
        /// <summary>
        /// 机器销售经理姓名
        /// </summary>
        public string sale_name { get; set; }
        /// <summary>
        /// 售后提交图片时间
        /// </summary>
        public DateTime? screenshot_subtime { get; set; }
        /// <summary>
        /// 提交人姓名
        /// </summary>
        public string screenshot_subname { get; set; }
        /// <summary>
        /// 提交人uid
        /// </summary>
        public string screenshot_subuid { get; set; }
    }

    public class MchForSearchPic : Mch
    {
        public string baseusername { get; set; }

        public string baseuserLoginname { get; set; }
    }
    /// <summary>
    /// 升级状态
    /// </summary>
    public enum updateState
    {
        升级成功 = 1,
        升级失败 = 10,
        主程序损坏 = 11
    }
    public class MchByBatch : BaseEnity
    {

        public string SN { get; set; }//SN
        public string Name { get; set; }//名称
        public string Number { get; set; }//编号
        public string GroupId { get; set; }  //场地 
        public MchState State { get; set; }
        public bool IsOnLine { get; set; }  //是否在线  

        [NotMapped]
        public string StateName { get; set; }
        [NotMapped]
        public string GroupName { get; set; }  //场地 
        public string BaseUserId { get; set; }  //信号   
        public string Key { get; set; }  //信号 
        public string Remark { get; set; }  //备注   
        public bool Active { get; set; }  //是否激活   

        public string MchMode { get; set; }  //机器型号  

        public string Address { get; set; }  //详细地址
        public string Lng { get; set; }
        public string Lat { get; set; }

        public string PlaceId { get; set; }
        public decimal? BillChangefundAmount { get; set; }//纸币数
        public decimal? CoinChangefundAmount { get; set; }// 硬币数

        public bool IsAutoRefund { get; set; }//是否出货失败自动退款
        public string TmpStrategyId { get; set; }//温度策略ID
        public string TmpStrategyContent { get; set; }//温度策略内容
        public string LightStrategyId { get; set; }//灯光策略ID
        public string PriceStrategyId { get; set; }//价格策略ID

        public string AdId { get; set; }//广告策略ID

        public string channelId { get; set; }//安卓版本

        public string ConnUpdateOn { get; set; }//连接状态改变

        public string MchVesion { get; set; }//程序版本 

        public bool OrderFromClient { get; set; }//部分定值机客户端计算价格 

        /// <summary>
        /// 出厂日期
        /// </summary>
        public DateTime? OutTime { get; set; }
        /// <summary>
        /// 指定保修时间
        /// </summary>
        public int? AddMonth { get; set; }
        /// <summary>
        /// 保修日期
        /// </summary>
        [Required]
        public DateTime? GuaranteeTime { get; set; }
        /// <summary>
        /// 设备所属批次
        /// </summary>
        public string BatchID { get; set; }

        /// <summary>
        /// 批次编号
        /// </summary>
        public string Batch_No { get; set; }
        /// <summary>
        /// 设备型号
        /// </summary>
        public string MchModel { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string BatchRemark { get; set; }

        /// <summary>
        /// 当前真实的掉货检测值
        /// </summary>
        public bool TrueDropCheck { get; set; }
        /// <summary>
        /// 设置是否开启掉货检测
        /// </summary>
        public bool SetDropCheck { get; set; }

        /// <summary>
        /// 当前使用版本
        /// </summary>
        [MaxLength(50)]
        public string app_Version { get; set; }
        /// <summary>
        /// 程序升级情况
        /// </summary>
        public updateState app_updateState { get; set; } = updateState.升级成功;
        /// <summary>
        /// 程序升级备注
        /// </summary>
        [MaxLength(500)]
        public string app_updateRemark { get; set; }

        public string province { get; set; }
        public string city { get; set; }

        public string district { get; set; }
        /// <summary>
        /// 当前亮度
        /// </summary>
        public decimal? brightness { get; set; }

        /// <summary>
        /// 当前广告ID
        /// </summary>
        public string now_ad_id { get; set; }
        /// <summary>
        ///  当年广告名称
        /// </summary>
        public string now_ad_name { get; set; }
        /// <summary>
        /// 广告类型
        /// </summary>
        public int? ad_type { get { return ad_typeinfo; } set { this.ad_typeinfo = value; } }
        /// <summary>
        ///  广告是否下发 成功
        /// </summary>
        public bool? ad_success { get; set; }
        public string Daemon_channelId { get; set; }//安卓版本

        public string Daemon_ConnUpdateOn { get; set; }//连接状态改变
        public bool Daemon_IsOnline { get; set; }

        private int? ad_typeinfo = null;

        public string ad_type_str { get { return ad_typeinfo == null ? "无记录" : ad_typeinfo.ToString(); } }
        public string assurance_sdt { get; set; }


    }

    [Table("Mch_Model")]
    public class Mch_Model
    {
        [Key, MaxLength(300)]
        /// <summary>
        ///  
        /// </summary>
        public string Mch_Model_Id { get; set; }
        /// <summary>
        /// 机器型号
        /// </summary>
        [MaxLength(300)]
        public string MchModel { get; set; }

        public DateTime Add_Time { get; set; }
        [MaxLength(50)]
        public string Baseuserid { get; set; }
    }
    [Table("Mch_Batch")]
    public class Mch_Batch
    {
        [Key, MaxLength(50)]
        /// <summary>
        /// 批次ID
        /// </summary>
        public string BatchID { get; set; }
        [MaxLength(300)]
        /// <summary>
        /// 批次编号
        /// </summary>
        public string Batch_No { get; set; }
        [MaxLength(300)]
        /// <summary>
        /// 设备型号
        /// </summary>
        public string MchModel { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime Add_Time { get; set; }
        /// <summary>
        /// 添加人
        /// </summary>
        [MaxLength(50)]
        public string Baseuserid { get; set; }
    }
    /// <summary>
    /// 修改报修信息时用到的机器列表
    /// </summary>
    public class MchListByGuaranteeTime
    {


        /// <summary>
        /// 批次ID
        /// </summary>
        public string BatchID { get; set; }

        /// <summary>
        /// 批次编号
        /// </summary>
        public string Batch_No { get; set; }

        /// <summary>
        /// 设备型号
        /// </summary>
        public string MchModel { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime Add_Time { get; set; }
        /// <summary>
        /// 添加人
        /// </summary>

        public string Baseuserid { get; set; }
        public string MchId { get; set; }

        public string Name { get; set; }
        /// <summary>
        /// 出厂日期
        /// </summary>
        public DateTime? OutTime { get; set; }
        /// <summary>
        /// 保修日期
        /// </summary>
        public DateTime? GuaranteeTime { get; set; }
    }

    public class SearchMch_CMD_Log
    {
        public string Id { get; set; }
        /// <summary>
        /// 机器ID
        /// </summary>
        public string Mchid { get; set; }
        /// <summary>
        /// 机器SN
        /// </summary>
        public string Sn { get; set; }
        /// <summary>
        /// 指令类型
        /// </summary>
        public Cmd_Type c_type { get; set; }
        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime? SendTime { get { return Sendtime; } set { Sendtime = value; F_name = !value.HasValue ? "" : value.Value.ToString("yyyyMMddHHmm_截屏"); } }
        /// <summary>
        /// 收到返回时间
        /// </summary>
        public DateTime? PostTime { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string ex_Url { get; set; }
        /// <summary>
        /// 发送状态
        /// </summary>
        public int SendState { get; set; }

        public string Baseuserid { get; set; }
        private DateTime? Sendtime = null;
        private string F_name = "unknow";
        public string filename { get { return F_name; } }
    }
    /// <summary>
    /// 机器指令送达日志
    /// </summary>
    public class Mch_CMD_Log
    {
        public string Id { get; set; }
        /// <summary>
        /// 机器ID
        /// </summary>
        public string Mchid { get; set; }
        /// <summary>
        /// 机器SN
        /// </summary>
        public string Sn { get; set; }
        /// <summary>
        /// 指令类型
        /// </summary>
        public Cmd_Type c_type { get; set; }
        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime SendTime { get; set; }
        /// <summary>
        /// 收到返回时间
        /// </summary>
        public DateTime? PostTime { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string ex_Url { get; set; }
        /// <summary>
        /// 发送状态
        /// </summary>
        public int SendState { get; set; }

        public string Baseuserid { get; set; }

 
    }
    public enum Cmd_Type
    {
        关机 = 0,
        重启 = 1,
        截屏 = 2,
        亮度 = 3
    }



    public enum MchState
    {
        未分配 = 20005,
        可用 = 20001,
        停用 = 20002,
        未激活 = 20003,
        禁用 = 20004,  //禁用时，用户不能改变状态，只能由管理员来更改状态
    }
    /// <summary>
    ///  设置机器管理权限 
    /// </summary>
    public class Mch_Role
    {
        public string Id { get; set; }
        public string Mchid { get; set; }

        public string Userid { get; set; }
    }

    public class kid_mch_role
    {
        public string ID { get; set; }
        public string baseuserid { get; set; }
        public List<string> mchids { get; set; }
    }

    /// <summary>
    ///机器APP版本搜索
    /// </summary>
    public class Mch_AppVersionSearch
    {
        public string ID { get; set; }
        public string ProjectName { get; set; }

        public string SN { get; set; }//SN 
        public string Name { get; set; }//名称
        public bool IsOnLine { get; set; }  //是否在线  
        public string BaseUserId { get; set; }
        public string Daemon_channelId { get; set; }//安卓版本

        public string Daemon_ConnUpdateOn { get; set; }//连接状态改变
        public bool Daemon_IsOnline { get; set; }
        /// <summary>
        /// 守护程序上次上级时间
        /// </summary>
        public DateTime? Daemon_lastupdate_time { get; set; }
        /// <summary>
        /// 守护程序上次升级成功时间
        /// </summary>
        public DateTime? Daemon_lastupdatesuccess_time { get; set; }
        /// <summary>
        /// 守护程序版本
        /// </summary> 
        public string Daemon_Version { get; set; }
        /// <summary>
        /// 守护程序版本备注
        /// </summary> 
        public string Daemon_updateRemark { get; set; }
        /// <summary>
        /// 程序升级情况
        /// </summary>
        public updateState Daemon_updateState { get; set; } = updateState.升级成功;

        /// <summary>
        /// 当前使用版本
        /// </summary> 
        public string app_Version { get; set; }
        /// <summary>
        /// 程序升级情况
        /// </summary>
        public updateState app_updateState { get; set; } = updateState.升级成功;
        /// <summary>
        /// 程序升级备注
        /// </summary> 
        public string app_updateRemark { get; set; }
        /// <summary>
        /// 当前使用的包名
        /// </summary>  
        public string packageName { get; set; } = "unknow";
        /// <summary>
        /// 守护程序包名
        /// </summary>
        public string Daemon_packageName { get; set; }
        /// <summary>
        /// App上次升级时间
        /// </summary>
        public DateTime? app_lastupdate_time { get; set; }
        /// <summary>
        /// APP上次升级成功时间
        /// </summary>
        public DateTime? app_lastupdatesuccess_time { get; set; }
        /// <summary>
        /// 项目ID 
        /// </summary>
        public string AppProject_Id { get; set; }
        public string MchVesion { get; set; }//程序版本 

    }
    public class MqttSendResult
    {
        public bool success { get; set; }
        public string msg { get; set; }
        public string mchid { get; set; }
        public string mchname { get; set; }
    }

    //[{"VersionType":"MV","UpdateTime":"2019-11-27","BoardTime":"2019-12-5"}]
    public class Mchinfo
    {
        private string VT = "";
        public string type_chgange(string itemname) {
            switch (itemname)
            {
                case "MV": return "主柜";
                case "T": return "第一副柜";
                case "Fir": return "第二副柜";
                case "Sec": return "第三副柜";
                case "Thi": return "温控板";
                default: return itemname;
            }
        }
        public string VersionType { get { return VT; } set { VT = type_chgange(value); } }
        public string UpdateTime { get; set; } 
        public string BoardTime { get; set; }
    }
    /// <summary>
    /// 
    /// </summary>
    public class search_rk_mchlist
    {
        public List<Mchinfo> mch_info_list { get; set; }
        public string iccid { get; set; }
        public string Key { get; set; }
        public string Id { get; set; }
        /// <summary>
        /// SN
        /// </summary>
        public string SN { get; set; }

        public string Name { get; set; }

        public string MchType { get; set; }
        /// <summary>
        /// 质保开始时间
        /// </summary>
        public DateTime? assurance_sdt { get; set; }
        /// <summary>
        /// 是否存在照片
        /// </summary>
        public bool? have_pic { get; set; }

        public string wxrecord_screenshot { get; set; }

        public string tallyafter_screenshot { get; set; }

        public string service_tel { get; set; }

        public DateTime? work_order_time { get; set; }

        public string work_order_id { get; set; }

        public string sale_uid { get; set; }

        public string sale_name { get; set; }
    }

    public class search_rk_adminmchlist : search_rk_mchlist
    {
        public string baseusername { get; set; }
        public bool? IsOnLine { get; set; }

        public string UserName { get; set; }
    }
    /// <summary>
    /// 设置机器微信图片
    /// </summary>
    public class set_mch_pic_parmas
    {
        public string Id { get; set; }
        public string[] wxrecord_screenshot { get; set; }

        public string[] tallyafter_screenshot { get; set; }
    }
    /// <summary>
    ///  设置机器属性
    /// </summary>
    public class set_mch_parmas
    {
        public string Id { get; set; }
        public string MchType { get; set; }
        public DateTime? assurance_sdt { get; set; }
        public string service_tel { get; set; }
    }
    public enum ad_type
    {
        图片 = 0,
        视频 = 1,
        无广告 = 2
    }

    public class getMchs_params
    {
        public string baseuserid { get; set; } = "";
        public string username { get; set; } = "";
        public string number { get; set; } = "";
        public string name { get; set; } = "";
        public string id { get; set; } = "";
        public string sn { get; set; } = "";
        public string groupid { get; set; } = "";
        public bool IsPage { get; set; } = true;
        public int page { get; set; } = 1;
        public int pagesize { get; set; } = 20;
        public bool? updateSearch { get; set; } = null;
        public kid_mch_role mchrole { get; set; } = null;
        public ad_type? usetype { get; set; } = null;
    }
}